using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
using ZR.Model.Dto.Business.ProductionControl;
using ZR.Model.Models.ProductionControl;
using ZR.Service.IService.ProductionControl;

//创建时间：2024-09-29
namespace ZR.Admin.WebApi.Controllers
{
    /// <summary>
    /// 工站信息表
    /// </summary>
    [Verify]
    [Route("review/stationworkinfo")]
    [ApiExplorerSettings(GroupName = "business")]
    public class StationWorkInfoController : BaseController
    {
        /// <summary>
        /// 工站信息表接口
        /// </summary>
        private readonly IStationWorkInfoService _StationWorkInfoService;

        public StationWorkInfoController(IStationWorkInfoService StationWorkInfoService)
        {
            _StationWorkInfoService = StationWorkInfoService;
        }

        /// <summary>
        /// 查询工站信息表列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "review:stationworkinfo:list")]
        public IActionResult QueryStationWorkInfo([FromQuery] StationWorkInfoQueryDto parm)
        {
            var response = _StationWorkInfoService.GetList(parm);
            return SUCCESS(response);
        }

        /// <summary>
        /// 查询工站信息表详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "review:stationworkinfo:query")]
        public IActionResult GetStationWorkInfo(int Id)
        {
            var response = _StationWorkInfoService.GetInfo(Id);

            var info = response.Adapt<StationWorkInfoDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加工站信息表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "review:stationworkinfo:add")]
        [Log(Title = "工站信息表", BusinessType = BusinessType.INSERT)]
        public IActionResult AddStationWorkInfo([FromBody] StationWorkInfoDto parm)
        {
            var modal = parm.Adapt<StationWorkInfo>().ToCreate(HttpContext);

            var response = _StationWorkInfoService.AddStationWorkInfo(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新工站信息表
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "review:stationworkinfo:edit")]
        [Log(Title = "工站信息表", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateStationWorkInfo([FromBody] StationWorkInfoDto parm)
        {
            var modal = parm.Adapt<StationWorkInfo>().ToUpdate(HttpContext);
            var response = _StationWorkInfoService.UpdateStationWorkInfo(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除工站信息表
        /// </summary>
        /// <returns></returns>
        [HttpDelete("delete/{ids}")]
        [ActionPermissionFilter(Permission = "review:stationworkinfo:delete")]
        [Log(Title = "工站信息表", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteStationWorkInfo([FromRoute] string ids)
        {
            var idArr = Tools.SplitAndConvert<int>(ids);

            return ToResponse(_StationWorkInfoService.Delete(idArr));
        }
    }
}